#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int nums1[N];
int nums2[N];
int n, m;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> nums1[i];
    for (int i = 0; i < m; i++)
        cin >> nums2[i];
        int i=0,j=0;
        while(i<n&&j<m)
        {
            if(nums2[j]!=nums1[i])
            {
                j++;
            }
            else
            {
                i++;
                j++;
            }
        }
        if(i>=n)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    return 0;
}